home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Database Designers / Rational Rose 2000 / Rational Setup.EXE / common / lib / MSWin32-x86 / auto / DynaLoader / dl_findfile.al < prev   
Encoding:
Text File  |  1999-01-26  |  3.3 KB  |  86 lines

  1. # NOTE: Derived from ../LIB\DynaLoader.pm.
  2. # Changes made here will be lost when autosplit again.
  3. # See AutoSplit.pm.
  4. package DynaLoader;
  5.  
  6. #line 203 "../LIB\DynaLoader.pm (autosplit into ..\lib\auto/DynaLoader/dl_findfile.al)"
  7. sub dl_findfile {
  8.     # Read ext/DynaLoader/DynaLoader.doc for detailed information.
  9.     # This function does not automatically consider the architecture
  10.     # or the perl library auto directories.
  11.     my (@args) = @_;
  12.     my (@dirs,  $dir);   # which directories to search
  13.     my (@found);         # full paths to real files we have found
  14.     my $dl_ext= 'dll'; # $Config::Config{'dlext'} suffix for perl extensions
  15.     my $dl_so = 'dll'; # $Config::Config{'so'} suffix for shared libraries
  16.  
  17.     print STDERR "dl_findfile(@args)\n" if $dl_debug;
  18.  
  19.     # accumulate directories but process files as they appear
  20.     arg: foreach(@args) {
  21.         #  Special fast case: full filepath requires no search
  22.         if ($Is_VMS && m%[:>/\]]% && -f $_) {
  23.         push(@found,dl_expandspec(VMS::Filespec::vmsify($_)));
  24.         last arg unless wantarray;
  25.         next;
  26.         }
  27.         elsif (m:/: && -f $_ && !$do_expand) {
  28.         push(@found,$_);
  29.         last arg unless wantarray;
  30.         next;
  31.     }
  32.  
  33.         # Deal with directories first:
  34.         #  Using a -L prefix is the preferred option (faster and more robust)
  35.         if (m:^-L:) { s/^-L//; push(@dirs, $_); next; }
  36.  
  37.         #  Otherwise we try to try to spot directories by a heuristic
  38.         #  (this is a more complicated issue than it first appears)
  39.         if (m:/: && -d $_) {   push(@dirs, $_); next; }
  40.  
  41.         # VMS: we may be using native VMS directry syntax instead of
  42.         # Unix emulation, so check this as well
  43.         if ($Is_VMS && /[:>\]]/ && -d $_) {   push(@dirs, $_); next; }
  44.  
  45.         #  Only files should get this far...
  46.         my(@names, $name);    # what filenames to look for
  47.         if (m:-l: ) {          # convert -lname to appropriate library name
  48.             s/-l//;
  49.             push(@names,"lib$_.$dl_so");
  50.             push(@names,"lib$_.a");
  51.         } else {                # Umm, a bare name. Try various alternatives:
  52.             # these should be ordered with the most likely first
  53.             push(@names,"$_.$dl_ext")    unless m/\.$dl_ext$/o;
  54.             push(@names,"$_.$dl_so")     unless m/\.$dl_so$/o;
  55.             push(@names,"lib$_.$dl_so")  unless m:/:;
  56.             push(@names,"$_.a")          if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
  57.             push(@names, $_);
  58.         }
  59.         foreach $dir (@dirs, @dl_library_path) {
  60.             next unless -d $dir;
  61.             chop($dir = VMS::Filespec::unixpath($dir)) if $Is_VMS;
  62.             foreach $name (@names) {
  63.         my($file) = "$dir/$name";
  64.                 print STDERR " checking in $dir for $name\n" if $dl_debug;
  65.         $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file);
  66.         #$file = _check_file($file);
  67.         if ($file) {
  68.                     push(@found, $file);
  69.                     next arg; # no need to look any further
  70.                 }
  71.             }
  72.         }
  73.     }
  74.     if ($dl_debug) {
  75.         foreach(@dirs) {
  76.             print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
  77.         }
  78.         print STDERR "dl_findfile found: @found\n";
  79.     }
  80.     return $found[0] unless wantarray;
  81.     @found;
  82. }
  83.  
  84. # end of DynaLoader::dl_findfile
  85. 1;
  86.